package mo.tags.greedy;

import java.util.PriorityQueue;

public class L179 {

    public String largestNumber(int[] nums) {
        PriorityQueue<String> heap = new PriorityQueue<>((x, y) -> (y+x).compareTo(x+y));
        for (int num : nums) {
            heap.offer(String.valueOf(num));
        }
        StringBuilder builder = new StringBuilder();
        while (!heap.isEmpty()) {
            builder.append(heap.poll());
        }
        if (builder.charAt(0) == '0') {
            return "0";
        }
        return builder.toString();
    }

    public static void main(String[] args) {
        L179 test = new L179();
        System.out.println(test.largestNumber(new int[]{3,30,34,5,9}));
    }


}
